/**
 * Created by lx on 2017/4/21.
 */
// 处理获取子列表的reducer
import * as types from '../../constants/CreatePage';
// 子列表
const oneSubList = [{
  'itemId': 917,
  'country': 'CN',
  'division': 'REFS',
  'itemName': 'Campus New Request',
  'itemDescription': 'Campus New Request',
  'ou': 'CHINA_REFS',
  'businessRole': 'china_requester',
  'everybody': 1,
  'isForMarketing': 0,
  'isForMedical': 0,
  'isForSales': 0
}, {
  'itemId': 918,
  'country': 'CN',
  'division': 'REFS',
  'itemName': 'process',
  'itemDescription': 'HTC Apply Process',
  'ou': 'CHINA_REFS',
  'businessRole': 'china_requester',
  'everybody': 1,
  'isForMarketing': 0,
  'isForMedical': 0,
  'isForSales': 0
}, {
  'itemId': 919,
  'country': 'CN',
  'division': 'REFS',
  'itemName': 'Permit work process',
  'itemDescription': 'Permit work process',
  'ou': 'CHINA_REFS',
  'businessRole': 'china_requester',
  'everybody': 1,
  'isForMarketing': 0,
  'isForMedical': 0,
  'isForSales': 0
}];
const twoSubList = [{
  'itemId': 927,
  'country': 'CN',
  'division': 'REFS',
  'itemName': 'Campus New Request',
  'itemDescription': 'Campus New Request',
  'ou': 'CHINA_REFS',
  'businessRole': 'china_requester',
  'everybody': 1,
  'isForMarketing': 0,
  'isForMedical': 0,
  'isForSales': 0
}, {
  'itemId': 928,
  'country': 'CN',
  'division': 'REFS',
  'itemName': 'process',
  'itemDescription': 'HTC Apply Process',
  'ou': 'CHINA_REFS',
  'businessRole': 'china_requester',
  'everybody': 1,
  'isForMarketing': 0,
  'isForMedical': 0,
  'isForSales': 0
}, {
  'itemId': 929,
  'country': 'CN',
  'division': 'REFS',
  'itemName': 'Permit work process',
  'itemDescription': 'Permit work process',
  'ou': 'CHINA_REFS',
  'businessRole': 'china_requester',
  'everybody': 1,
  'isForMarketing': 0,
  'isForMedical': 0,
  'isForSales': 0
}, {
  'itemId': 930,
  'country': 'CN',
  'division': 'REFS',
  'itemName': 'Campus New Request',
  'itemDescription': 'Campus New Request',
  'ou': 'CHINA_REFS',
  'businessRole': 'china_requester',
  'everybody': 1,
  'isForMarketing': 0,
  'isForMedical': 0,
  'isForSales': 0
}];
// 一开始应该传的是一个空的对象
export default function createPageLI(state = [], action) {

  switch (action.type) {
    case types.GET_SUBLIST:
      if (action.params == 'categoryId97') {
        const temp = {
          close: false
        };
        if (state.length == 0) {
          return oneSubList;
        } else if (state.close == true) {
          oneSubList.close = false;
          return oneSubList;
        } else if (state.close == false) {
          return Object.assign([], oneSubList, temp);
        } else {
          return oneSubList;
        }
      } else if (action.params == 'categoryId98') {
        const temp = {
          close: false
        };
        if (state.length == 0) {
          return twoSubList;
        } else if (state.close == true) {
          oneSubList.close = false;
          return twoSubList;
        } else if (state.close == false) {
          return Object.assign([], twoSubList, temp);
        } else {
          return twoSubList;
        }
      } else if (action.params == '关闭') {
        const temp = {
          close: true
        };
        console.log(state);
        if (state.length == 0) {
          return Object.assign([], state, temp);
        } else if (state.close == true) {
          state.close = false;
          return state;
        } else {
          return Object.assign([], state, temp);
        }
      }
    // 其他
    default:
      return state;
  }
}
